// store.js
import { observable, action } from 'mobx-miniprogram'

export const store = observable({

  // 数据字段
  numA: 1,
  numB: 2,
  carsNum:0,
  tabBarActive:1,
  showPercent: true,

  // 计算属性
  get sum() {
    return this.numA + this.numB
  },

  // actions
  update: action(function () {
    const sum = this.sum
    this.numA = this.numB
    this.numB = sum
  }),
  updateCars: action(function (step) {
    const cars = this.carsNum
    this.carsNum =  step
  }),
  updateActives: action(function (index) {
    this.tabBarActive =  index
  }),
  updateShowPercent: action(function(step){
    this.showPercent = step
  })
})